package java02.ui;

import java02.bll.standard.Shape;
import java02.bll.Retangle;
import java02.bll.standard.ShapeOperation;
import java02.bll.Square;

// 客户--求长方形或正方形的面积（基于规范的求解方式）
public class Client {
    public static void main(String[] args) {
//        Shape obj = new Shape(); 抽象类不能实例化为对象
//        double area = square.getArea(); 不符合规范
        // 规范化的求正方形面积和周长方式
        /*Square square = new Square(5);
        square.setOffset(100);
        double area = ShapeOperation.areaOperation(square);
        double perimeter = ShapeOperation.perimeterOperation(square);*/
        //父类型的引用可以指向子类型的对象
        Shape shape = new Square(5);
        shape.setOffset(100);
        double area = ShapeOperation.areaOperation(shape);
        double perimeter = ShapeOperation.perimeterOperation(shape);

        // 规范化的求长方形面积和周长方式
        /*Retangle retangle = new Retangle(5, 4);
        area = ShapeOperation.areaOperation(retangle);
        perimeter = ShapeOperation.perimeterOperation(retangle);*/

        shape = new Retangle(5, 4);
        area = ShapeOperation.areaOperation(shape);
        perimeter = ShapeOperation.perimeterOperation(shape);
    }
}

